# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
import codecs
import json

# useful for handling different item types with a single interface
from itemadapter import ItemAdapter

from dumpDB.items import MyEncoder_DumpfileItem
from utils import dbUtils


class DumpfilePipeline:
    def __init__(self):
        self.table = 'ai_db.news'

    def process_item(self, item, spider):
        dbUtils.inser_table(self.table, item)
        return item

    def close_spider(self, spider):
        dbUtils.close_conn()